/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.ruby_string.delayed;

import moved.org.objectweb.asm.Label;
import moved.org.objectweb.asm.MethodVisitor;

public class JumpInstruction extends AbstractMethodInstruction {
	private final int opcode;
	private final Label label;

	public JumpInstruction(int opcode, Label label) {
		this.opcode = opcode;
		this.label = label;
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// MethodInstruction Methods
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	public void accept(MethodVisitor methodVisitor) {
		methodVisitor.visitJumpInsn(opcode, label);
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// Object Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	@Override
	public boolean equals(Object object) {
		if (object == null || !(object.getClass().equals(getClass()))) {
			return false;
		}
		
		JumpInstruction other = (JumpInstruction) object;
		
		return opcode == other.opcode &&
			label.equals(other.label);
	}
}
